﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BLL;
using Config;
using Intorise.Config;
using Intorise.Framework;

namespace AutoCheckGuildWar
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
            this.txtCode.Text = Security.GetCode();
            this.txtSN.Text = ConfigManager.AppConfig.SerialNumber;
        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(this.txtCode.Text);
            this.toolTip1.Show("机器码已复制", this,this.btnCopy.Location,2000);
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSN.Text)) { return; }
            ConfigManager.AppConfig.SerialNumber = txtSN.Text;
            ConfigForm.SaveConfig(null);
            var code = Security.GetCode();
            if (Security.Validate(Security.GetCode(), txtSN.Text).Success)
            {
                MessageBox.Show("注册成功！");
                this.Close();
            }
            else
            {
                MessageBox.Show("注册信息有误！");
            }
        }
    }
}